package com.example.model;

import lombok.Data;
import java.time.LocalDateTime;

@Data
public class DbConnection {
    private Long id;
    private Long userId;
    private String name;
    private String dbType;
    private String host;
    private Integer port;
    private String databaseName;
    private String username;
    private String password;
    private Boolean isDefault;
    private LocalDateTime createdAt;
    private LocalDateTime updatedAt;
    
    // 创建无密码的拷贝，用于安全传输到前端
    public DbConnection withoutPassword() {
        DbConnection copy = new DbConnection();
        copy.setId(this.id);
        copy.setUserId(this.userId);
        copy.setName(this.name);
        copy.setDbType(this.dbType);
        copy.setHost(this.host);
        copy.setPort(this.port);
        copy.setDatabaseName(this.databaseName);
        copy.setUsername(this.username);
        copy.setPassword("********"); // 隐藏真实密码
        copy.setIsDefault(this.isDefault);
        copy.setCreatedAt(this.createdAt);
        copy.setUpdatedAt(this.updatedAt);
        return copy;
    }
} 